<template>
  <div class="dashboard-container">
    <el-row :gutter="20">
      <el-col :span="6">
        <el-card shadow="hover" class="dashboard-card">
          <template #header>
            <div class="card-header">
              <span>文章总数</span>
            </div>
          </template>
          <div class="card-content">
            <div class="card-value">128</div>
            <div class="card-icon">
              <el-icon>
                <el-icon-document/>
              </el-icon>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="6">
        <el-card shadow="hover" class="dashboard-card">
          <template #header>
            <div class="card-header">
              <span>用户总数</span>
            </div>
          </template>
          <div class="card-content">
            <div class="card-value">256</div>
            <div class="card-icon">
              <el-icon>
                <el-icon-user/>
              </el-icon>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="6">
        <el-card shadow="hover" class="dashboard-card">
          <template #header>
            <div class="card-header">
              <span>评论总数</span>
            </div>
          </template>
          <div class="card-content">
            <div class="card-value">512</div>
            <div class="card-icon">
              <el-icon>
                <el-icon-chat-dot-round/>
              </el-icon>
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="6">
        <el-card shadow="hover" class="dashboard-card">
          <template #header>
            <div class="card-header">
              <span>访问量</span>
            </div>
          </template>
          <div class="card-content">
            <div class="card-value">1024</div>
            <div class="card-icon">
              <el-icon>
                <el-icon-view/>
              </el-icon>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" style="margin-top: 20px;">
      <el-col :span="12">
        <el-card shadow="hover">
          <template #header>
            <div class="card-header">
              <span>最近一周访问量</span>
            </div>
          </template>
          <div style="height: 300px;">
            <!-- 这里可以放置图表组件 -->
            <div style="text-align: center; line-height: 300px; color: #909399;">
              图表区域（实际项目中可以使用ECharts等图表库）
            </div>
          </div>
        </el-card>
      </el-col>

      <el-col :span="12">
        <el-card shadow="hover">
          <template #header>
            <div class="card-header">
              <span>最新文章</span>
            </div>
          </template>
          <el-table :data="latestArticles" style="width: 100%">
            <el-table-column prop="title" label="标题"/>
            <el-table-column prop="date" label="发布日期" width="180"/>
            <el-table-column prop="views" label="浏览量" width="100"/>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {ref} from 'vue'

export default {
  name: 'Dashboard',
  setup() {
    const latestArticles = ref([
      {title: '如何使用Vue3进行开发', date: '2023-05-20', views: 328},
      {title: 'Element Plus组件库介绍', date: '2023-05-18', views: 256},
      {title: '前端开发最佳实践', date: '2023-05-15', views: 198},
      {title: 'JavaScript高级技巧分享', date: '2023-05-10', views: 176},
      {title: 'CSS布局技巧总结', date: '2023-05-05', views: 145}
    ])

    return {
      latestArticles
    }
  }
}
</script>

<style scoped>
.dashboard-container {
  padding: 20px;
}

.dashboard-card {
  height: 100%;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-value {
  font-size: 28px;
  font-weight: bold;
  color: #303133;
}

.card-icon {
  font-size: 40px;
  color: #909399;
}
</style>
